﻿@model SrBBSPro.Entities.HolidayNote
@{
    ViewBag.Title = "休假详细";
    Layout = "~/Views/Shared/_LayoutPage.cshtml";    
}

<div class="main layui-clear">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>@Model.User.StaffName 的 @Model.HolidayCount.Title</legend>
    </fieldset>
    <div class="layui-form layui-form-pane">
        <form method="post" action="@Url.Action("Save","Count")">
            @Html.AntiForgeryToken()
            <input type="hidden" name="Id" id="Id"  value="@Model.Id" />
            <input type="hidden" name="No" id="No"  value="@Model.User.Id"/>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label for="filename" class="layui-form-label">假期开始：</label>
                    <div class="layui-input-block">
                        <input id="hstartDate" class="layui-input" readonly="readonly" value="@Model.HolidayCount.StartDate.ToString("yyyy/MM/dd")">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">假期结束</label>
                    <div class="layui-input-block">
                        <input id="hendDate" class="layui-input" readonly="readonly" value="@Model.HolidayCount.EndDate.ToString("yyyy/MM/dd")">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label for="filename" class="layui-form-label">开始时间：</label>
                    <div class="layui-input-block">
                        <input id="StartDate" name="StartDate" class="layui-input" readonly="readonly" 
                               value="@Model.StartDate.ToString("yyyy/MM/dd")" required lay-verify="date">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">结束时间</label>
                    <div class="layui-input-block">
                        <input id="EndDate" name="EndDate" class="layui-input" readonly="readonly" 
                               value="@Model.EndDate.ToString("yyyy/MM/dd")" required lay-verify="date">
                    </div>
                </div>
                <div class="layui-inline">
                    <div class="layui-input-inline">
                        <label class="layui-form-label" id="days">假期共 @Model.Days 天</label>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <button id="btnSubmit" class="layui-btn layui-btn-normal" lay-filter="add" lay-submit>信息提交</button>
            </div>
        </form>
    </div>
</div>
@section scripts{
    <script>
        layui.use(['laydate', 'jquery', 'count'], function () {
            var $ = layui.jquery;
            var laydate = layui.laydate;
            var count = layui.count;
            var uid = layui.data('user').user.uid;
            var userId = '@Model.No';
           
            if (uid == userId) {
                laydate.render({
                    elem: '#StartDate'
                    , type: 'date'
                    , trigger: 'click'
                    , format: 'yyyy/MM/dd'
                    , theme: '#558AC0'
                    , calendar: true
                    , done: function (value) {
                        count.compareDate(value, $('#EndDate').val(), $("#hstartDate").val(), $("#hendDate").val());
                    }
                });

                laydate.render({
                    elem: '#EndDate'
                    , type: 'date'
                    , trigger: 'click'
                    , format: 'yyyy/MM/dd'
                    , theme: '#558AC0'
                    , calendar: true
                    , done: function (value) {
                        count.compareDate($('#StartDate').val(), value, $("#hstartDate").val(), $("#hendDate").val());
                    }
                });
            } else {
                $("#btnSubmit").css("display", "none");
            }

        });
    </script>
}